package com.shijie.controller.erp;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.shijie.core.Result;
import com.shijie.core.ResultGenerator;
import com.shijie.core.annotation.RequiresPermissions;
import com.shijie.domain.entity.Talents;
import com.shijie.domain.entity.Users;
import com.shijie.service.TalentsService;

/*
 *  @author: smart boy
 *  @date: 2018-09-08
 */
@RestController
@RequestMapping("/erp/talents")
public class TalentsController {

    @Resource
	private TalentsService talentsService;

    @RequiresPermissions(value={"vip:list"})
 	@GetMapping
 	public Result list(@RequestParam(defaultValue = "1") Integer page,
 			@RequestParam(defaultValue = "10") Integer pageSize,Users user) {
 		return ResultGenerator.success(talentsService.selectTalentsByPage(page, pageSize, user));
 	}

	@PostMapping
    public Result add(@RequestBody Users talents) {
        talentsService.save(talents);
        return ResultGenerator.success();
	}
	
	@PostMapping("bind")
    public Result bind(@RequestBody Users talents) {
        talentsService.bind(talents);
        return ResultGenerator.success();
	}
	
	@PutMapping("sort")
    public Result sort(@RequestBody Users talents) {
        talentsService.sort(talents);
        return ResultGenerator.success();
	}

    @GetMapping("/{id}")
    public Result detail(@PathVariable Integer id) {
    	Users talents = talentsService.getTalentsDetail(id);
        return ResultGenerator.success(talents);
	}
}

